package com.imooc.Thread;

/**
 * Created by Administrator on 2017/7/17.
 */
class BaseThread extends Thread {

    private Integer num = 0;
    private String name;

    public BaseThread() {
    }

    public BaseThread(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i < 16; i++) {
            System.out.println(this.name + ":" + num ++);
            try {
                this.sleep(8);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        super.run();
    }

    public static void main(String[] args) throws InterruptedException {
        BaseThread ts = new BaseThread("first thread");
        BaseThread ts2 = new BaseThread("second thread");
        ts.start();
        Thread.sleep(32);
        ts2.start();
    }
}
